const { View , Text , Button} = require("@tarojs/components");
import './MineBookedDetails.less'
import http from '../../../../utils/http'
import Taro , {useReady} from '@tarojs/taro'
import React, { useState} from 'react'

const add=(b)=>{
    Taro.navigateTo({
        url:'/pages/YXX/payAdd/payAdd?id='+b,
    })
}

const cancel=(b)=>{
    Taro.navigateTo({
        url:'/pages/HXM/CancelRefund/CancelRefund?id='+b,
    })
}

function MineBookedDetails () {

    const [index,setIndex]=useState('')
    const [sum,setSum]=useState()
    const [id,setId]=useState('')
    const [arr,setArr]=useState({})

    useReady(() => {
		setId(Taro.getCurrentInstance().router.params.id)
        setIndex(Taro.getCurrentInstance().router.params.index)
        http({   //获取我的体检详细
            url:"/getaccomplishphysical",
            data:{
                order_orderId:Taro.getCurrentInstance().router.params.id
            },
            header:{
                'content-type': 'application/json' 
            },
        }).then((res)=>{
            setArr(res[0])
            setSum(res[0].contentPrice+res[0].phy_salePrice)
        })
      })

      const onDateChange = e => {
        this.setState({
          dateSel: e.detail.value
        })
      }

      const onChange = e => {
        this.setState({
          selectorChecked: this.state.selector[e.detail.value]
        })
      }

return(
    <view>
		<view>
			<view className="view1" >
				<view className="view1-1">
					<text>{arr.user_name} {arr.user_tel}</text>
				</view>
				<view className="view1-2">
					<view>
						体检机构: <text> {arr.org_Name}</text>
					</view>
					<view>
						体检时间: <text> {arr.order_date}</text>
					</view>
					<view>
						体检单号: <text> {arr.productId}</text>
					</view>
				</view>
			</view>
			<view className="view2">
				<view className="view2-1">
					<text>订单编号：{arr.order_orderId}</text>
				</view>
				<view className="view2-2">
					<view>
						<text>{arr.order_orderId}</text>
						<text>￥{arr.contentPrice}</text>
					</view>
					<view>
						<text>{arr.phy_projectName}</text>
						<text>￥{arr.phy_salePrice}</text>
					</view>
					<view>
						<text style="color:red">合计</text>
						<text style="color:red">￥{sum}</text>
					</view>
				</view>
			</view>
			<view className="view3">
				<button type="primary" plain="true" onClick={add.bind(this,id)}>我要加项</button>
			</view>
		</view>
		<view className="view4">
			<button type="primary" plain="true" onClick={cancel.bind(this,id)}>取消预约</button>
			<picker mode="date" onChange={onDateChange}>
				<button type="primary" plain="true"><view className="picker">修改时间</view></button>
			</picker>
		</view>
	</view>
)

}
export default MineBookedDetails